<?php

class Action extends CI_Controller {

	function __construct(){
		parent::__construct();
	}

	function atopic(){
		$pid = (int)$this->uri->segment(4,0);
		if(!$pid){
			echo json_encode(array('status'=>false,'msg'=>'传参错误!'));exit;
		}
		$content = trim($this->input->post('content'));
		if(!$content){
			echo json_encode(array('status'=>false,'msg'=>'话题内容不能为空！!'));exit;
		}
		$title = trim($this->input->post('title'));
		if(!$title){
			echo json_encode(array('status'=>false,'msg'=>'话题标题不能为空！!'));exit;
		}
		
		$this->load->model('topic_model');
		$r = $this->topic_model->add_topic($pid,$title,$content);
		if($r['status']){
			echo json_encode(array('status'=>true,'tid'=>$r['tid']));exit;
		}else{
			echo json_encode(array('status'=>false,'msg'=>'回复失败，可能网络问题!'));exit;
		}
	}
}